import request from './request.js'

//根据id和类型查询通知详情
export function getDetailIdByIdAndType(id, type){
	return request({
		url: '/notice',
		method: 'GET',
		params: {
			id,
			type
		}
	})
}

//更新通知详情
export function updateDetail(id,title,value,render){
	return request({
		url: '/notice',
		method: 'POST',
		data:{
			id: id,
			title: title,
			detailMd: value,
			detailHtml: render
		}
	})
}

//获取所有通知详情
export function getAllDetail(){
	return request({
		url: '/notice/page',
		method: 'POST',
		params: {
			currentPage: 1,
			pageSize: 20
		},
		data: {
			conditions: []
		}
	})
}

// 根据用户ID查询所有详细
export function getNoticesByCondition(currentPage, pageSize, searchConditions){
	return request({
		url: '/notice/page',
		method: 'POST',
		params: {
			currentPage, pageSize
		},
		data: {
			conditions: searchConditions
		}
	})
}

//添加通知
export function addNotice(form){
	return request({
		url: '/notice',
		method: 'POST',
		data:{
			id: null,
			uid: form.uid,
			title: form.title,
			source: form.source
		}
	})
}

//删除通知
export function delNotice(id){
	return request({
		url: '/notice',
		method: 'DELETE',
		params: {
			id
		}
	})
}

//批量删除通知
export function delNoticeByBatch(idsStr){
	return request({
		url: '/notice/batch',
		method: 'DELETE',
		params:{
			idsStr
		}
	})
}
